﻿<%@ Page Title="" Language="C#" MasterPageFile="~/_Default.Master" AutoEventWireup="true" CodeBehind="MessageBoard.aspx.cs" Inherits="WebApplication.MessageBoard" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="layui-row" style="width: 1200px;">
        <div class="layui-col-md10 layui-col-md-offset1 layui-col-sm10 layui-col-sm-offset1">
            <div class="layui-panel mt-10">
                <div class="layui-row" style="padding: 50px 30px;">
                    <div class="layui-col-md10 layui-col-md-offset1 layui-col-sm10 layui-col-sm-offset1">
                        <div class="layui-form-item">
                            <label class="layui-form-label">联系方式</label>
                            <div class="layui-input-block">
                                <input type="text" name="Contact" lay-verify="Contact" autocomplete="off" placeholder="请输入联系方式" class="layui-input" />
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">留言内容</label>
                            <div class="layui-input-block">
                                <textarea name="Content" lay-verify="Content" placeholder="请输入留言内容" class="layui-textarea"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn layui-btn-danger-2" lay-submit="" lay-filter="submit-btn">立即提交</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        layui.use(['form', 'jquery'], function () {
            var $ = layui.jquery,
                form = layui.form,
                layer = layui.layer;

            // 进行登录操作
            form.on('submit(submit-btn)', function (data) {
                data = data.field;
                if (!data.Contact) {
                    layer.msg("联系方式不能为空！")
                    return false;
                }
                if (!data.Content) {
                    layer.msg("留言内容不能为空！")
                    return false;
                }
                console.log(data)
                $.ajax({
                    url: "/MessageBoardHandle/Handle.aspx",
                    method: "post",
                    data: {
                        action:"Insert",
                        Content: data.Content,
                        Contact: data.Contact
                    },
                    success: () => {
                        //layer.alert("用户信息修改成功", (index) => {
                        //    layer.closeAll();
                        //    location.reload()
                        //});
                        location.href = "/";
                    }
                })
                return true;
            });
        });
    </script>
</asp:Content>
